package com.xfcycle.zebrabikegp.assist;

import com.xfcycle.zebrabikegp.bean.AlarmInfoResult;

import java.util.HashMap;
import java.util.Map;

/**
 * 警报辅助类
 * Created by Wilson on 2017/7/7.
 */

public class AlarmAssist {

    //搜索到的蓝牙设备列表
    private static Map<String, AlarmInfoResult> alarmInfoMap;

    private AlarmAssist() {
        alarmInfoMap = new HashMap<>();
    }

    private static AlarmAssist instance;

    public static boolean isAlarm = false;

    public static AlarmAssist getInstance() {
        if (null == instance) {
            instance = new AlarmAssist();
        }
        return instance;
    }

    /**
     * 添加警报信息
     */
    public void addAlarmInfo(String alarmBike, AlarmInfoResult AlarmInfoResult) {
        alarmInfoMap.put(alarmBike, AlarmInfoResult);
    }

    /**
     * 获取警报信息
     */
    public AlarmInfoResult getAlarmInfoByBike(String alarmBike) {
        return alarmInfoMap.get(alarmBike);
    }

    /**
     * 获取所有警报信息列表
     */
    public Map getAlarmInfoMap() {
        return alarmInfoMap;
    }

    /**
     * 删除特定警报信息
     * @param alarmBike
     */
    public void removeAlarmInfoByBike(String alarmBike){
        alarmInfoMap.remove(alarmBike);
    }

    /**
     * 清空警报信息
     */
    public void cleanAlarmInfos(){
        alarmInfoMap.clear();
    }

    /**
     * 判断是否有报警信息
     */
    public boolean isAlarmExist() {
        if (alarmInfoMap.size() <= 0) {
            return false;
        }
        return true;
    }
}